home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / gtlayout / source / lt_getmenuitem.c < prev    next >
C/C++ Source or Header  |  1999-04-19  |  2KB  |  83 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1998 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. /*****************************************************************************/
  15.  
  16. #include <stddef.h>
  17.  
  18. /*****************************************************************************/
  19.  
  20. #include "Assert.h"
  21.  
  22. /*****************************************************************************/
  23.  
  24. #ifdef DO_MENUS    /* Support code */
  25.  
  26. /****** gtlayout.library/LT_GetMenuItem ******************************************
  27. *
  28. *   NAME
  29. *    LT_GetMenuItem -- Get the menu/submenu item associated with an ID (V11)
  30. *
  31. *   SYNOPSIS
  32. *    Item = LT_GetMenuItem(Menu,ID)
  33. *     D0                    A0  D0
  34. *
  35. *    struct MenuItem *LT_GetMenuItem(struct Menu *,ULONG);
  36. *
  37. *   FUNCTION
  38. *    This routine scans through all menu items associated with the
  39. *    menu and returns a pointer to the item associated with the
  40. *    given ID value.
  41. *
  42. *   INPUTS
  43. *    Menu - Pointer to Menu structure as returned by LT_NewMenuTagList.
  44. *
  45. *    ID - Unique ID of the item to find.
  46. *
  47. *   RESULT
  48. *    Item - Pointer to the struct MenuItem * in question or NULL
  49. *        if none could be found
  50. *
  51. *   SEE ALSO
  52. *    gtlayout.library/LT_NewMenuTagList
  53. *
  54. ******************************************************************************
  55. *
  56. */
  57.  
  58.     /* LT_GetMenuItem(struct Menu *Menu,ULONG ID):
  59.      *
  60.      *    Obtain the menu item associated with the ID.
  61.      */
  62.  
  63. struct MenuItem * LIBENT
  64. LT_GetMenuItem(REG(a0) struct Menu *Menu,REG(d0) ULONG ID)
  65. {
  66.     RootMenu *Root = (RootMenu *)((ULONG)Menu - offsetof(RootMenu,Menu));
  67.     ItemNode *Item;
  68.  
  69.         // Run down the list...
  70.  
  71.     for(Item = (ItemNode *)Root->ItemList.mlh_Head ; Item->Node.mln_Succ ; Item = (ItemNode *)Item->Node.mln_Succ)
  72.     {
  73.         if(Item->ID == ID)
  74.             return(&Item->Item);
  75.     }
  76.  
  77.         // Nothing found
  78.  
  79.     return(NULL);
  80. }
  81.  
  82. #endif    /* DO_MENUS */
  83.